package leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-12-11 23:10
 **/
public class LeetCode5935 {

    public List<Integer> goodDaysToRobBank(int[] security, int time) {
        int[] left = new int[security.length], right = new int[security.length];
        for (int i = 1; i < security.length; i++) {
            left[i] = security[i] > security[i - 1] ? 0 : left[i - 1] + 1;
        }
        for (int i = security.length - 2; i >= 0; i--) {
            right[i] = security[i] > security[i + 1] ? 0 : right[i + 1] + 1;
        }
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < security.length; i++) {
            if (left[i] >= time && right[i] >= time) {
                list.add(i);
            }
        }
        return list;
    }

}
